<?php
/*
 * 企业名企
 * @author  Mark
 * @package ixdcw
 * @file    show.inc.php
 * @time    12-12-13 下午2:03
 */
defined('IN_IXDCW') or exit('Access Denied');
require DT_CORE.'/'.$module.'/common.inc.php';
// itemid 没有传参
$itemid or dheader($MOD['linkurl']);
$item = $db->getOne("SELECT * FROM {$table} WHERE itemid=$itemid");
$thumb=$item['thumb'];
$introduce=$item['introduce'];

//适用车品牌
$arbid=$item['arbid'];
$bandname=get_carName($arbid, $key = 'arid', $from = 'name');
//适用车车系
$chid=$item['arcid'];
$chexiname=get_carName($chid, $key = 'arid', $from = 'name');
// item正常
if($item && $item['status'] >= 2) {
	// 是外链
	if($item['islink']) dheader($item['linkurl']);
	// 获取变量
	extract($item);
} else {
	$head_title = lang('message->item_not_exists');
	@header("HTTP/1.1 404 Not Found");
	exit(include template('show-notfound', 'message'));
}
// 分类的ID属性
$CAT = get_cat($catid);

$t = $db->getOne("SELECT * FROM {$table_data} WHERE itemid=$itemid");
$content = $t['content'];

// 时间格式
$adddate = timetodate($addtime);
$editdate = timetodate($edittime);

if(check_group($_groupid, $MOD['group_contact'])) {
    if($fee) {
        $user_status = 4;
    } else {
        $user_status = 3;
        $member = $item['username'] ? userinfo($item['username']) : array();

        if($item['totime'] && $item['totime'] < $DT_TIME && $item['status'] == 3) $update .= ",status=4";
        if($member) {
            foreach(array('groupid', 'vip','validated','company','areaid','truename','telephone','mobile','address','qq','msn','ali','skype') as $v) {
                if($item[$v] != $member[$v]) $update .= ",$v='".addslashes($member[$v])."'";
            }
            if($item['email'] != $member['mail']) $update .= ",email='$member[mail]'";
        }
    }
} else {
    $user_status = $_userid ? 1 : 0;
    if($_username && $item['username'] == $_username) {
        $member = userinfo($item['username']);
        $user_status = 3;
    }
}

$linkurl = linkurl($linkurl, 1);
$titles = array();
// 分页标题
if($subtitle) {
	$titles = explode("\n", $subtitle);
	$titles = array_map('trim', $titles);
}
$subtitle = isset($titles[$page-1]) ? $titles[$page-1] : '';
// 关键词
$keytags = $tag ? explode(' ', $tag) : array();
$update = '';

// 不需要花费费用.
$user_status = 3;

$pages = '';
// 子标题处理
$subtitles = count($titles);
if(strpos($content, '[pagebreak]') !== false) {
	$content = explode('[pagebreak]', $content);
	$total = count($content);
	$pages = showpages($item, $total, $page);
	$content = $content[$page-1];
	if($total < $subtitles) $subtitles = $total;
}
// 内容关联链接
if($MOD['keylink']) $content = keylink($content, $moduleid);
include DT_INC.'/update.inc.php';
// seo 文件
$seo_file = 'show';
include DT_INC.'/seo.inc.php';
if($subtitle) $seo_title = $subtitle.$seo_delimiter.$seo_title;
// 模版, 检查类和模块
$template = 'show';
//if($MOD['template_show']) $template = $MOD['template_show'];
//if($CAT['show_template']) $template = $CAT['show_template'];
//if($item['template']) $template = $item['template'];
include template($template, $module);
?>